﻿using System;
///OutputCalendar
namespace OutputCalendar;
internal class Program
{
    const int monthWidth = 35;
    const int monthHeight = 8;
    static void Main(string[] args)
    {
       
        DateTime day = new DateTime(2022, 1, 1);
        //Make sure the first day
        int x = 0, y = 0, theFirstWeekday = 0;
        do
        {
            if (day.Day == 1)  //Determine initial position of the month
            {
                x = ((day.Month - 1) % 3) * monthWidth;
                y = ((day.Month - 1) / 3) * monthHeight;
                Console.SetCursorPosition(x, y);
                //Output name of the month
                Console.Write("{0,15}月", day.Month);
                //convert to the new line
                Console.SetCursorPosition(x, y + 1);
                //Output week//Output week
                Console.Write("日  一  二  三  四  五  六");
                theFirstWeekday = Convert.ToInt32(day.DayOfWeek);
                
            }
            int dayofweek = Convert.ToInt32(day.DayOfWeek);
            Console.SetCursorPosition(x + dayofweek*4 , y + (int)Math.Ceiling((day.Day + theFirstWeekday) / 7.0) + 1);
            Console.Write("{0,1}", day.Day);
            day = day.AddDays(1);
        } while (day.Year == 2022);
      
        Console.ReadLine();
    }
}    
                    
            
            
        
                       
                
                    
           
   
           

                
                    
                
                
            
            
               
   